<template>
  <div class="formSelect">
    <el-select v-model="value" v-bind="$attrs" :multiple='$attrs.node.isRadio' filterable clearable @change="getValue">
      <el-option v-for="item in $attrs.node.options" :key="item.value" :label="item.label" :value="item.value">
      </el-option>
    </el-select>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        value: this.$attrs.node.default,  //根据多选单选赋默认值，不然由于数据类型发生变化会直接初始化触发校验规则
      }
    },
    mounted() {
      const {node} = this.$attrs
      this.$emit('emitValue', node.default)
    },
    methods: {
      getValue(val) {
        this.$emit('emitValue', val)
      },
      reset(){
        this.value = this.$attrs.node.default
      }
    }
  }
</script>